package com.secf.service.port.hpy.hys.test.day3;

import java.util.Arrays;

/**
 * @Author ms
 * @Date 2024-08-08
 */
public class ArrayTest {

    public static void main(String[] args) {
        // 测试数组的排序
        int[] numbers = {10, 5, 8, 3, 9};
        Arrays.sort(numbers);
        System.out.println("排序后的数组: " + Arrays.toString(numbers));

        // 测试二分查找
        int index = Arrays.binarySearch(numbers, 8);
        System.out.println("数字8的索引: " + index);

        // 测试数组的复制
        int[] copiedArray = Arrays.copyOf(numbers, 7);
        System.out.println("复制后的数组: " + Arrays.toString(copiedArray));

        // 测试数组的填充
        Arrays.fill(copiedArray, 6);
        System.out.println("填充后的数组: " + Arrays.toString(copiedArray));
    }
}
